Component({
  mixins: [],
  data: {
    personLimit:'3',
    dayLimit:'100',
    shareNumber:'6',
    isFavor:0,
    labelCol: { fixedSpan: 7 },
    wrapperCol: { span: 17 },
  },
  props: {},
  didMount() { 
    this.loadDefault()
  },
  didUpdate() { },
  didUnmount() { },
  methods: {
  
    onChange(e) {
      let {
        detail: { value },
        currentTarget: { dataset }
      } = e;
      let { name } = dataset;
      console.log(name + ' onChange:', value);
      this.setData({ [name]: value });
    },

    async handleSubmit() {
      let sendData={
        shop_id:getApp().globalData.shop_id,
        personLimit:this.data.personLimit,
        dayLimit:this.data.dayLimit,
        shareNumber:this.data.shareNumber,
        isFavor:this.data.isFavor
      };
      const { cloud } = getApp();
      const res = await cloud.application.httpRequest({
        path: '/index.php/index/qn/game',
        method: 'POST',
        params: sendData
      });
      if (res) {
        my.alert({
          title: '温馨提示',
          content: '提交成功！'
        })
        this.loadDefault()
      }
    },
    async loadDefault(){
      const {cloud} =getApp();
      const res=await cloud.application.httpRequest({
        path:'/index.php/index/qn/getgame',
        method:'GET',
        params:{
          shop_id:getApp().globalData.shop_id
        }
      })
      if(res){
        this.setData({
          personLimit:res.personLimit,
          dayLimit:res.dayLimit,
          shareNumber:res.shareNumber,
          isFavor:res.isFavor
        })
      }
    }
  },
});

